using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Requests.Objects;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
	[TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "admin" })]
	public class OnlineCustomerInfosController : BaseController
	{
		private readonly IOnlineCustomerInfosServer _onlineCustomerInfosServer;
		public OnlineCustomerInfosController(IOnlineCustomerInfosServer onlineCustomerInfosServer)
		{
			_onlineCustomerInfosServer = onlineCustomerInfosServer;
		}
		/// <summary>
		/// 添加
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Add(RequestOnlineCustomerInfosDto dto)
		{
			return Send(await _onlineCustomerInfosServer.AddAsync(dto));
		}
		/// <summary>
		/// 删除
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Delete(RequestOnlineCustomerInfosDto dto)
		{
			return Send(await _onlineCustomerInfosServer.DeleteAsync(dto));
		}
		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Update(RequestOnlineCustomerInfosDto dto)
		{
			return Send(await _onlineCustomerInfosServer.UpdateAsync(dto));
		}
		/// <summary>
		/// 分页
		/// </summary>
		/// <param></param>
		/// <returns></returns>
		[HttpGet]
		public async Task<IActionResult> Pagination(int page,int limit,string key)
		{
            var soue = _account;
            return Send(await _onlineCustomerInfosServer.PaginationAsync(page,limit,key, soue.AId));
		}
    }
}
